{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f130cb46",
   "metadata": {},
   "source": [
    "<img src=\"https://s1.ax1x.com/2022/04/08/L9z54g.png\" width=50%>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d87639fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1219\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "        toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1219\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) {\n",
       "        if (callback != null)\n",
       "          callback();\n",
       "      });\n",
       "    } finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.debug(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(css_urls, js_urls, callback) {\n",
       "    if (css_urls == null) css_urls = [];\n",
       "    if (js_urls == null) js_urls = [];\n",
       "\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
       "\n",
       "    function on_load() {\n",
       "      root._bokeh_is_loading--;\n",
       "      if (root._bokeh_is_loading === 0) {\n",
       "        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
       "        run_callbacks()\n",
       "      }\n",
       "    }\n",
       "\n",
       "    function on_error(url) {\n",
       "      console.error(\"failed to load \" + url);\n",
       "    }\n",
       "\n",
       "    for (let i = 0; i < css_urls.length; i++) {\n",
       "      const url = css_urls[i];\n",
       "      const element = document.createElement(\"link\");\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error.bind(null, url);\n",
       "      element.rel = \"stylesheet\";\n",
       "      element.type = \"text/css\";\n",
       "      element.href = url;\n",
       "      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
       "      document.body.appendChild(element);\n",
       "    }\n",
       "\n",
       "    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\": \"XypntL49z55iwGVUW4qsEu83zKL3XEcz0MjuGOQ9SlaaQ68X/g+k1FcioZi7oQAc\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\": \"bEsM86IHGDTLCS0Zod8a8WM6Y4+lafAL/eSiyQcuPzinmWNgNO2/olUF0Z2Dkn5i\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\": \"TX0gSQTdXTTeScqxj6PVQxTiRW8DOoGVwinyi1D3kxv7wuxQ02XkOxv0xwiypcAH\"};\n",
       "\n",
       "    for (let i = 0; i < js_urls.length; i++) {\n",
       "      const url = js_urls[i];\n",
       "      const element = document.createElement('script');\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error.bind(null, url);\n",
       "      element.async = false;\n",
       "      element.src = url;\n",
       "      if (url in hashes) {\n",
       "        element.crossOrigin = \"anonymous\";\n",
       "        element.integrity = \"sha384-\" + hashes[url];\n",
       "      }\n",
       "      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.head.appendChild(element);\n",
       "    }\n",
       "  };\n",
       "\n",
       "  function inject_raw_css(css) {\n",
       "    const element = document.createElement(\"style\");\n",
       "    element.appendChild(document.createTextNode(css));\n",
       "    document.body.appendChild(element);\n",
       "  }\n",
       "\n",
       "  \n",
       "  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\"];\n",
       "  var css_urls = [];\n",
       "  \n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "    \n",
       "    \n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if (root.Bokeh !== undefined || force === true) {\n",
       "      \n",
       "    for (var i = 0; i < inline_js.length; i++) {\n",
       "      inline_js[i].call(root, root.Bokeh);\n",
       "    }\n",
       "    if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1219\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(css_urls, js_urls, function() {\n",
       "      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1219\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) {\n        if (callback != null)\n          callback();\n      });\n    } finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.debug(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(css_urls, js_urls, callback) {\n    if (css_urls == null) css_urls = [];\n    if (js_urls == null) js_urls = [];\n\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n    function on_load() {\n      root._bokeh_is_loading--;\n      if (root._bokeh_is_loading === 0) {\n        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n        run_callbacks()\n      }\n    }\n\n    function on_error(url) {\n      console.error(\"failed to load \" + url);\n    }\n\n    for (let i = 0; i < css_urls.length; i++) {\n      const url = css_urls[i];\n      const element = document.createElement(\"link\");\n      element.onload = on_load;\n      element.onerror = on_error.bind(null, url);\n      element.rel = \"stylesheet\";\n      element.type = \"text/css\";\n      element.href = url;\n      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n      document.body.appendChild(element);\n    }\n\n    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\": \"XypntL49z55iwGVUW4qsEu83zKL3XEcz0MjuGOQ9SlaaQ68X/g+k1FcioZi7oQAc\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\": \"bEsM86IHGDTLCS0Zod8a8WM6Y4+lafAL/eSiyQcuPzinmWNgNO2/olUF0Z2Dkn5i\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\": \"TX0gSQTdXTTeScqxj6PVQxTiRW8DOoGVwinyi1D3kxv7wuxQ02XkOxv0xwiypcAH\"};\n\n    for (let i = 0; i < js_urls.length; i++) {\n      const url = js_urls[i];\n      const element = document.createElement('script');\n      element.onload = on_load;\n      element.onerror = on_error.bind(null, url);\n      element.async = false;\n      element.src = url;\n      if (url in hashes) {\n        element.crossOrigin = \"anonymous\";\n        element.integrity = \"sha384-\" + hashes[url];\n      }\n      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.head.appendChild(element);\n    }\n  };\n\n  function inject_raw_css(css) {\n    const element = document.createElement(\"style\");\n    element.appendChild(document.createTextNode(css));\n    document.body.appendChild(element);\n  }\n\n  \n  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\"];\n  var css_urls = [];\n  \n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    function(Bokeh) {\n    \n    \n    }\n  ];\n\n  function run_inline_js() {\n    \n    if (root.Bokeh !== undefined || force === true) {\n      \n    for (var i = 0; i < inline_js.length; i++) {\n      inline_js[i].call(root, root.Bokeh);\n    }\n    if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1219\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(css_urls, js_urls, function() {\n      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import figure,show,output_notebook\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from bokeh.embed import file_html\n",
    "from bokeh.io import output_notebook,show \n",
    "from bokeh.layouts import layout \n",
    "from bokeh.models import (\n",
    "    ColumnDataSource, Plot, Circle, Range1d, LinearAxis, HoverTool, NumeralTickFormatter,\n",
    "    Text, SingleIntervalTicker, Slider, CustomJS, Legend, LegendItem, CategoricalColorMapper)  # 底层样式\n",
    "from bokeh.palettes import Spectral6\n",
    "\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3868bee1",
   "metadata": {},
   "source": [
    "## 柱状图"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2d33d56",
   "metadata": {},
   "source": [
    "### 基本柱状图"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "904cd00c",
   "metadata": {},
   "source": [
    "#### 1. 垂直柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4fdbcdda",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"4305c69c-ba76-4519-81c6-2ad6e2ceecfb\" data-root-id=\"1220\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"fa2e2e5a-6678-483b-bdd5-4dc683b2e654\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1229\"}],\"center\":[{\"id\":\"1232\"},{\"id\":\"1236\"}],\"height\":400,\"left\":[{\"id\":\"1233\"}],\"renderers\":[{\"id\":\"1254\"}],\"title\":{\"id\":\"1278\"},\"toolbar\":{\"id\":\"1244\"},\"width\":400,\"x_range\":{\"id\":\"1221\"},\"x_scale\":{\"id\":\"1225\"},\"y_range\":{\"id\":\"1223\"},\"y_scale\":{\"id\":\"1227\"}},\"id\":\"1220\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1237\",\"type\":\"PanTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1243\"}},\"id\":\"1239\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1221\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"top\":{\"field\":\"top\"},\"width\":{\"value\":0.5},\"x\":{\"field\":\"x\"}},\"id\":\"1252\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1241\",\"type\":\"ResetTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"red\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"red\"},\"top\":{\"field\":\"top\"},\"width\":{\"value\":0.5},\"x\":{\"field\":\"x\"}},\"id\":\"1253\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1223\",\"type\":\"DataRange1d\"},{\"attributes\":{\"source\":{\"id\":\"1251\"}},\"id\":\"1255\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1240\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1225\",\"type\":\"LinearScale\"},{\"attributes\":{\"formatter\":{\"id\":\"1280\"},\"major_label_policy\":{\"id\":\"1282\"},\"ticker\":{\"id\":\"1234\"}},\"id\":\"1233\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1227\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1278\",\"type\":\"Title\"},{\"attributes\":{\"formatter\":{\"id\":\"1283\"},\"major_label_policy\":{\"id\":\"1285\"},\"ticker\":{\"id\":\"1230\"}},\"id\":\"1229\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1242\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1287\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1230\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1280\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis\":{\"id\":\"1229\"},\"ticker\":null},\"id\":\"1232\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1282\",\"type\":\"AllLabels\"},{\"attributes\":{\"data\":{\"top\":[1.2,2.5,3.7],\"x\":[1,2,3]},\"selected\":{\"id\":\"1286\"},\"selection_policy\":{\"id\":\"1287\"}},\"id\":\"1251\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1233\"},\"dimension\":1,\"ticker\":null},\"id\":\"1236\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"1251\"},\"glyph\":{\"id\":\"1252\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1253\"},\"view\":{\"id\":\"1255\"}},\"id\":\"1254\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1283\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"1237\"},{\"id\":\"1238\"},{\"id\":\"1239\"},{\"id\":\"1240\"},{\"id\":\"1241\"},{\"id\":\"1242\"}]},\"id\":\"1244\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1234\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1285\",\"type\":\"AllLabels\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1243\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1286\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1238\",\"type\":\"WheelZoomTool\"}],\"root_ids\":[\"1220\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
       "  var render_items = [{\"docid\":\"fa2e2e5a-6678-483b-bdd5-4dc683b2e654\",\"root_ids\":[\"1220\"],\"roots\":{\"1220\":\"4305c69c-ba76-4519-81c6-2ad6e2ceecfb\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1220"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制方法 → vbar()\n",
    "\n",
    "# 画布设置\n",
    "p = figure(plot_width=400, plot_height=400)\n",
    "\n",
    "p.vbar(x = [1,2,3], \n",
    "       width = 0.5, \n",
    "       bottom = 0, \n",
    "       top = [1.2, 2.5, 3.7], \n",
    "       color = \"red\" # 填充颜色\n",
    ")\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af56fb37",
   "metadata": {},
   "source": [
    "#### 2. 水平柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e5170131",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"96aa3232-c34f-48de-ab33-931b4cdff116\" data-root-id=\"1344\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"7f8b3252-8d7d-4ecb-aef7-998e1bc7145b\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1353\"}],\"center\":[{\"id\":\"1356\"},{\"id\":\"1360\"}],\"height\":400,\"left\":[{\"id\":\"1357\"}],\"renderers\":[{\"id\":\"1378\"}],\"title\":{\"id\":\"1413\"},\"toolbar\":{\"id\":\"1368\"},\"width\":400,\"x_range\":{\"id\":\"1345\"},\"x_scale\":{\"id\":\"1349\"},\"y_range\":{\"id\":\"1347\"},\"y_scale\":{\"id\":\"1351\"}},\"id\":\"1344\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1417\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1345\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1351\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"navy\"},\"height\":{\"value\":0.5},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"navy\"},\"right\":{\"field\":\"right\"},\"y\":{\"field\":\"y\"}},\"id\":\"1377\",\"type\":\"HBar\"},{\"attributes\":{},\"id\":\"1349\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1413\",\"type\":\"Title\"},{\"attributes\":{\"data_source\":{\"id\":\"1375\"},\"glyph\":{\"id\":\"1376\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1377\"},\"view\":{\"id\":\"1379\"}},\"id\":\"1378\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1347\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1418\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"1375\"}},\"id\":\"1379\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1366\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1420\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1421\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1422\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1367\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1361\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1365\",\"type\":\"ResetTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1367\"}},\"id\":\"1363\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1364\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1362\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"1415\"},\"major_label_policy\":{\"id\":\"1417\"},\"ticker\":{\"id\":\"1358\"}},\"id\":\"1357\",\"type\":\"LinearAxis\"},{\"attributes\":{\"formatter\":{\"id\":\"1418\"},\"major_label_policy\":{\"id\":\"1420\"},\"ticker\":{\"id\":\"1354\"}},\"id\":\"1353\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data\":{\"right\":[1.2,2.5,3.7],\"y\":[1,2,3]},\"selected\":{\"id\":\"1421\"},\"selection_policy\":{\"id\":\"1422\"}},\"id\":\"1375\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_color\":{\"value\":\"navy\"},\"height\":{\"value\":0.5},\"line_color\":{\"value\":\"navy\"},\"right\":{\"field\":\"right\"},\"y\":{\"field\":\"y\"}},\"id\":\"1376\",\"type\":\"HBar\"},{\"attributes\":{},\"id\":\"1415\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1358\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"1361\"},{\"id\":\"1362\"},{\"id\":\"1363\"},{\"id\":\"1364\"},{\"id\":\"1365\"},{\"id\":\"1366\"}]},\"id\":\"1368\",\"type\":\"Toolbar\"},{\"attributes\":{\"axis\":{\"id\":\"1357\"},\"dimension\":1,\"ticker\":null},\"id\":\"1360\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1354\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1353\"},\"ticker\":null},\"id\":\"1356\",\"type\":\"Grid\"}],\"root_ids\":[\"1344\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
       "  var render_items = [{\"docid\":\"7f8b3252-8d7d-4ecb-aef7-998e1bc7145b\",\"root_ids\":[\"1344\"],\"roots\":{\"1344\":\"96aa3232-c34f-48de-ab33-931b4cdff116\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1344"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制方法 → hbar()\n",
    "\n",
    "# 画布设置\n",
    "p = figure(plot_width = 400, plot_height = 400)\n",
    "\n",
    "p.hbar(y = [1, 2, 3], \n",
    "       height = 0.5, \n",
    "       left = 0, \n",
    "       right = [1.2, 2.5, 3.7], \n",
    "       color = \"navy\"\n",
    ")\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb326572",
   "metadata": {},
   "source": [
    "## 实践1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "05b4b32f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"e9c68a05-abe5-48f7-a93f-5478589f1f2d\" data-root-id=\"1481\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"dca3b333-587b-45e9-b8ec-c59d985919d0\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1492\"}],\"center\":[{\"id\":\"1494\"},{\"id\":\"1498\"},{\"id\":\"1530\"}],\"height\":350,\"left\":[{\"id\":\"1495\"}],\"renderers\":[{\"id\":\"1518\"}],\"title\":{\"id\":\"1482\"},\"toolbar\":{\"id\":\"1507\"},\"width\":800,\"x_range\":{\"id\":\"1484\"},\"x_scale\":{\"id\":\"1488\"},\"y_range\":{\"id\":\"1486\"},\"y_scale\":{\"id\":\"1490\"}},\"id\":\"1481\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"factors\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"]},\"id\":\"1484\",\"type\":\"FactorRange\"},{\"attributes\":{\"index\":2,\"label\":{\"value\":\"Nectarines\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1533\",\"type\":\"LegendItem\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"field\":\"colors\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"field\":\"colors\"},\"top\":{\"field\":\"counts\"},\"width\":{\"value\":0.6},\"x\":{\"field\":\"fruits\"}},\"id\":\"1517\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1521\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"text\":\"Fruit Counts\"},\"id\":\"1482\",\"type\":\"Title\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"1499\"},{\"id\":\"1500\"},{\"id\":\"1501\"},{\"id\":\"1502\"},{\"id\":\"1503\"},{\"id\":\"1504\"},{\"id\":\"1506\"}]},\"id\":\"1507\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1496\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"1521\"},\"major_label_policy\":{\"id\":\"1523\"},\"ticker\":{\"id\":\"1496\"}},\"id\":\"1495\",\"type\":\"LinearAxis\"},{\"attributes\":{\"items\":[{\"id\":\"1531\"},{\"id\":\"1532\"},{\"id\":\"1533\"},{\"id\":\"1534\"},{\"id\":\"1535\"},{\"id\":\"1536\"}],\"location\":\"top\",\"orientation\":\"horizontal\"},\"id\":\"1530\",\"type\":\"Legend\"},{\"attributes\":{\"fill_color\":{\"field\":\"colors\"},\"line_color\":{\"field\":\"colors\"},\"top\":{\"field\":\"counts\"},\"width\":{\"value\":0.6},\"x\":{\"field\":\"fruits\"}},\"id\":\"1516\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1480\"}},\"id\":\"1519\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1499\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1480\"},\"glyph\":{\"id\":\"1516\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1517\"},\"view\":{\"id\":\"1519\"}},\"id\":\"1518\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1524\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{},\"id\":\"1500\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1488\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"1526\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1504\",\"type\":\"HelpTool\"},{\"attributes\":{\"index\":1,\"label\":{\"value\":\"Pears\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1534\",\"type\":\"LegendItem\"},{\"attributes\":{\"start\":0},\"id\":\"1486\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1527\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1490\",\"type\":\"LinearScale\"},{\"attributes\":{\"formatter\":{\"id\":\"1524\"},\"major_label_policy\":{\"id\":\"1526\"},\"ticker\":{\"id\":\"1493\"}},\"id\":\"1492\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1493\",\"type\":\"CategoricalTicker\"},{\"attributes\":{},\"id\":\"1528\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data\":{\"colors\":[\"#3288bd\",\"#99d594\",\"#e6f598\",\"#fee08b\",\"#fc8d59\",\"#d53e4f\"],\"counts\":[5,3,4,2,4,6],\"fruits\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"]},\"selected\":{\"id\":\"1527\"},\"selection_policy\":{\"id\":\"1528\"}},\"id\":\"1480\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1492\"},\"grid_line_color\":\"red\",\"ticker\":null},\"id\":\"1494\",\"type\":\"Grid\"},{\"attributes\":{\"axis\":{\"id\":\"1495\"},\"dimension\":1,\"ticker\":null},\"id\":\"1498\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"COUNTS\",\"@counts\"]]},\"id\":\"1506\",\"type\":\"HoverTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1505\"}},\"id\":\"1501\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"index\":5,\"label\":{\"value\":\"Strawberries\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1536\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1502\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1503\",\"type\":\"ResetTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1505\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"index\":3,\"label\":{\"value\":\"Plums\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1535\",\"type\":\"LegendItem\"},{\"attributes\":{\"index\":0,\"label\":{\"value\":\"Apples\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1531\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1523\",\"type\":\"AllLabels\"},{\"attributes\":{\"index\":4,\"label\":{\"value\":\"Grapes\"},\"renderers\":[{\"id\":\"1518\"}]},\"id\":\"1532\",\"type\":\"LegendItem\"}],\"root_ids\":[\"1481\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
       "  var render_items = [{\"docid\":\"dca3b333-587b-45e9-b8ec-c59d985919d0\",\"root_ids\":[\"1481\"],\"roots\":{\"1481\":\"e9c68a05-abe5-48f7-a93f-5478589f1f2d\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1481"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 数据\n",
    "fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']\n",
    "counts = [5, 3, 4, 2, 4, 6]\n",
    "\n",
    "source = ColumnDataSource(data = dict(\n",
    "    fruits = fruits,\n",
    "    counts = counts,\n",
    "    colors = Spectral6\n",
    "))\n",
    "\n",
    "TOOLTIPS = [\n",
    "    ('COUNTS','@counts')\n",
    "]\n",
    "\n",
    "# 画布设置\n",
    "p = figure(x_range = fruits, \n",
    "           plot_height = 350, \n",
    "           plot_width = 800,\n",
    "           title = 'Fruit Counts',\n",
    "           tooltips = TOOLTIPS\n",
    "          )\n",
    "\n",
    "\n",
    "# 绘制\n",
    "p.vbar(x = 'fruits', \n",
    "       top = 'counts', \n",
    "       width = 0.6, \n",
    "       source = source,\n",
    "       legend_group = \"fruits\",\n",
    "       color = 'colors'\n",
    "       )\n",
    "\n",
    "p.y_range.start = 0 \n",
    "p.xgrid.grid_line_color = \"red\"\n",
    "\n",
    "# 图例设置\n",
    "p.legend.location = \"top\"\n",
    "p.legend.orientation = \"horizontal\"\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7bb4a707",
   "metadata": {},
   "source": [
    "## 实践2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f4e478c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.palettes import Spectral6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "eb914cdc",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"798801a7-d04e-403a-88a6-b8c349f4a986\" data-root-id=\"1642\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"cb22e823-8566-49ae-8df9-ef2836f53ade\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1653\"}],\"center\":[{\"id\":\"1655\"},{\"id\":\"1659\"},{\"id\":\"1691\"}],\"left\":[{\"id\":\"1656\"}],\"renderers\":[{\"id\":\"1679\"}],\"title\":{\"id\":\"1643\"},\"toolbar\":{\"id\":\"1668\"},\"width\":800,\"x_range\":{\"id\":\"1645\"},\"x_scale\":{\"id\":\"1649\"},\"y_range\":{\"id\":\"1647\"},\"y_scale\":{\"id\":\"1651\"}},\"id\":\"1642\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"index\":2,\"label\":{\"value\":\"pyecharts\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1696\",\"type\":\"LegendItem\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"1660\"},{\"id\":\"1661\"},{\"id\":\"1662\"},{\"id\":\"1663\"},{\"id\":\"1664\"},{\"id\":\"1665\"},{\"id\":\"1667\"}]},\"id\":\"1668\",\"type\":\"Toolbar\"},{\"attributes\":{\"items\":[{\"id\":\"1692\"},{\"id\":\"1693\"},{\"id\":\"1694\"},{\"id\":\"1695\"},{\"id\":\"1696\"},{\"id\":\"1697\"}],\"location\":\"top\",\"orientation\":\"horizontal\"},\"id\":\"1691\",\"type\":\"Legend\"},{\"attributes\":{\"index\":5,\"label\":{\"value\":\"ggplot2\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1693\",\"type\":\"LegendItem\"},{\"attributes\":{\"index\":4,\"label\":{\"value\":\"plotly\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1695\",\"type\":\"LegendItem\"},{\"attributes\":{\"index\":3,\"label\":{\"value\":\"seaborn\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1697\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1661\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1666\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"axis\":{\"id\":\"1653\"},\"grid_line_color\":null,\"ticker\":null},\"id\":\"1655\",\"type\":\"Grid\"},{\"attributes\":{\"data\":{\"color\":[\"#3288bd\",\"#99d594\",\"#e6f598\",\"#fee08b\",\"#fc8d59\",\"#d53e4f\"],\"stars\":[9678,11034,5387,6038,4928,3783],\"tools\":[\"matplotlib\",\"bokeh\",\"pyecharts\",\"seaborn\",\"plotly\",\"ggplot2\"]},\"selected\":{\"id\":\"1688\"},\"selection_policy\":{\"id\":\"1689\"}},\"id\":\"1641\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"formatter\":{\"id\":\"1685\"},\"major_label_policy\":{\"id\":\"1687\"},\"ticker\":{\"id\":\"1654\"}},\"id\":\"1653\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"field\":\"color\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"field\":\"color\"},\"top\":{\"field\":\"stars\"},\"width\":{\"value\":0.8},\"x\":{\"field\":\"tools\"}},\"id\":\"1678\",\"type\":\"VBar\"},{\"attributes\":{\"fill_color\":{\"field\":\"color\"},\"line_color\":{\"field\":\"color\"},\"top\":{\"field\":\"stars\"},\"width\":{\"value\":0.8},\"x\":{\"field\":\"tools\"}},\"id\":\"1677\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1682\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1651\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"1641\"},\"glyph\":{\"id\":\"1677\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1678\"},\"view\":{\"id\":\"1680\"}},\"id\":\"1679\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1684\",\"type\":\"AllLabels\"},{\"attributes\":{\"axis\":{\"id\":\"1656\"},\"dimension\":1,\"ticker\":null},\"id\":\"1659\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1649\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"1660\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1657\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1685\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"stars\",\"@stars\"],[\"tools\",\"@tools\"]]},\"id\":\"1667\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1654\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"overlay\":{\"id\":\"1666\"}},\"id\":\"1662\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1687\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1663\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1664\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1688\",\"type\":\"Selection\"},{\"attributes\":{\"source\":{\"id\":\"1641\"}},\"id\":\"1680\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"2019\\u5e747\\u6708\\u5e38\\u89c1\\u53ef\\u89c6\\u5316\\u5de5\\u5177Github\\u6807\\u661f\\u6570\\u91cf\"},\"id\":\"1643\",\"type\":\"Title\"},{\"attributes\":{\"factors\":[\"matplotlib\",\"bokeh\",\"pyecharts\",\"seaborn\",\"plotly\",\"ggplot2\"]},\"id\":\"1645\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"1689\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"index\":0,\"label\":{\"value\":\"matplotlib\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1694\",\"type\":\"LegendItem\"},{\"attributes\":{\"formatter\":{\"id\":\"1682\"},\"major_label_policy\":{\"id\":\"1684\"},\"ticker\":{\"id\":\"1657\"}},\"id\":\"1656\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1665\",\"type\":\"HelpTool\"},{\"attributes\":{\"end\":14000,\"start\":0},\"id\":\"1647\",\"type\":\"DataRange1d\"},{\"attributes\":{\"index\":1,\"label\":{\"value\":\"bokeh\"},\"renderers\":[{\"id\":\"1679\"}]},\"id\":\"1692\",\"type\":\"LegendItem\"}],\"root_ids\":[\"1642\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
       "  var render_items = [{\"docid\":\"cb22e823-8566-49ae-8df9-ef2836f53ade\",\"root_ids\":[\"1642\"],\"roots\":{\"1642\":\"798801a7-d04e-403a-88a6-b8c349f4a986\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1642"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = pd.read_csv('./week06_data.csv')\n",
    "\n",
    "source = ColumnDataSource(data = dict(\n",
    "    tools = df['Visualization_tools'],\n",
    "    stars = df['Star'],\n",
    "    color = Spectral6\n",
    "))\n",
    "\n",
    "TOOLTIPS = [\n",
    "    (\"stars\",'@stars'),\n",
    "    (\"tools\",\"@tools\")\n",
    "]\n",
    "\n",
    "# 画布设置\n",
    "p = figure(x_range = df['Visualization_tools'], \n",
    "           title = \"2019年7月常见可视化工具Github标星数量\", \n",
    "           tooltips = TOOLTIPS,\n",
    "           plot_width = 800\n",
    "           )\n",
    "\n",
    "p.vbar(x = 'tools', \n",
    "       top = 'stars', \n",
    "       width = 0.8, \n",
    "       source = source,\n",
    "       color = 'color',\n",
    "       legend_group = 'tools'\n",
    "       )\n",
    "\n",
    "# 其他设置\n",
    "p.xgrid.grid_line_color = None\n",
    "p.y_range.start = 0\n",
    "p.legend.location = \"top\"\n",
    "p.legend.orientation = \"horizontal\"\n",
    "p.y_range.end = 14000\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d18686d0",
   "metadata": {},
   "source": [
    "## 作业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "71a542c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from bokeh.models import FactorRange"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "db05e79c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"cafb3ea4-9532-454d-8295-eb952f1b5bd5\" data-root-id=\"3238\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"4cde87f2-d6dc-4b8d-a70d-66f416b15506\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"3246\"}],\"center\":[{\"id\":\"3248\"},{\"id\":\"3252\"}],\"height\":400,\"left\":[{\"id\":\"3249\"}],\"renderers\":[{\"id\":\"3270\"}],\"title\":{\"id\":\"3413\"},\"toolbar\":{\"id\":\"3260\"},\"width\":800,\"x_range\":{\"id\":\"3237\"},\"x_scale\":{\"id\":\"3242\"},\"y_range\":{\"id\":\"3240\"},\"y_scale\":{\"id\":\"3244\"}},\"id\":\"3238\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"3253\"},{\"id\":\"3254\"},{\"id\":\"3255\"},{\"id\":\"3256\"},{\"id\":\"3257\"},{\"id\":\"3258\"}]},\"id\":\"3260\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"3256\",\"type\":\"SaveTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"3259\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"start\":0},\"id\":\"3240\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"top\":{\"field\":\"counts\"},\"width\":{\"value\":0.9},\"x\":{\"field\":\"x\"}},\"id\":\"3268\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"3242\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"3417\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"3418\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"overlay\":{\"id\":\"3259\"}},\"id\":\"3255\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"3257\",\"type\":\"ResetTool\"},{\"attributes\":{\"formatter\":{\"id\":\"3418\"},\"major_label_orientation\":1,\"major_label_policy\":{\"id\":\"3420\"},\"ticker\":{\"id\":\"3247\"}},\"id\":\"3246\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"source\":{\"id\":\"3236\"}},\"id\":\"3271\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"3253\",\"type\":\"PanTool\"},{\"attributes\":{\"factors\":[[\"matplotlib\",\"stars\"],[\"matplotlib\",\"commits\"],[\"matplotlib\",\"contributors\"],[\"bokeh\",\"stars\"],[\"bokeh\",\"commits\"],[\"bokeh\",\"contributors\"],[\"pyecharts\",\"stars\"],[\"pyecharts\",\"commits\"],[\"pyecharts\",\"contributors\"],[\"seaborn\",\"stars\"],[\"seaborn\",\"commits\"],[\"seaborn\",\"contributors\"],[\"plotly\",\"stars\"],[\"plotly\",\"commits\"],[\"plotly\",\"contributors\"],[\"ggplot2\",\"stars\"],[\"ggplot2\",\"commits\"],[\"ggplot2\",\"contributors\"]],\"range_padding\":0.1},\"id\":\"3237\",\"type\":\"FactorRange\"},{\"attributes\":{},\"id\":\"3413\",\"type\":\"Title\"},{\"attributes\":{\"data_source\":{\"id\":\"3236\"},\"glyph\":{\"id\":\"3268\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"3269\"},\"view\":{\"id\":\"3271\"}},\"id\":\"3270\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"3421\",\"type\":\"Selection\"},{\"attributes\":{\"formatter\":{\"id\":\"3415\"},\"major_label_policy\":{\"id\":\"3417\"},\"ticker\":{\"id\":\"3250\"}},\"id\":\"3249\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"3254\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"3244\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"3422\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"3420\",\"type\":\"AllLabels\"},{\"attributes\":{\"axis\":{\"id\":\"3246\"},\"grid_line_color\":null,\"ticker\":null},\"id\":\"3248\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"top\":{\"field\":\"counts\"},\"width\":{\"value\":0.9},\"x\":{\"field\":\"x\"}},\"id\":\"3269\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"3247\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"data\":{\"counts\":[9678,29503,808,11034,17673,357,5387,1321,18,6038,2316,98,4928,3370,76,3783,4286,184],\"x\":[[\"matplotlib\",\"stars\"],[\"matplotlib\",\"commits\"],[\"matplotlib\",\"contributors\"],[\"bokeh\",\"stars\"],[\"bokeh\",\"commits\"],[\"bokeh\",\"contributors\"],[\"pyecharts\",\"stars\"],[\"pyecharts\",\"commits\"],[\"pyecharts\",\"contributors\"],[\"seaborn\",\"stars\"],[\"seaborn\",\"commits\"],[\"seaborn\",\"contributors\"],[\"plotly\",\"stars\"],[\"plotly\",\"commits\"],[\"plotly\",\"contributors\"],[\"ggplot2\",\"stars\"],[\"ggplot2\",\"commits\"],[\"ggplot2\",\"contributors\"]]},\"selected\":{\"id\":\"3421\"},\"selection_policy\":{\"id\":\"3422\"}},\"id\":\"3236\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"3415\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"3258\",\"type\":\"HelpTool\"},{\"attributes\":{\"axis\":{\"id\":\"3249\"},\"dimension\":1,\"ticker\":null},\"id\":\"3252\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"3250\",\"type\":\"BasicTicker\"}],\"root_ids\":[\"3238\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
       "  var render_items = [{\"docid\":\"4cde87f2-d6dc-4b8d-a70d-66f416b15506\",\"root_ids\":[\"3238\"],\"roots\":{\"3238\":\"cafb3ea4-9532-454d-8295-eb952f1b5bd5\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "3238"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "tools = df['Visualization_tools']\n",
    "factors = ['stars', 'commits', 'contributors']\n",
    "\n",
    "data = {\n",
    "    'tools' : tools,\n",
    "    'stars' : [9678, 11034, 5387, 6038, 4928, 3783],\n",
    "    'commits' : [29503, 17673, 1321, 2316, 3370, 4286],\n",
    "    'contributors' : [808, 357, 18, 98, 76, 184]\n",
    "}\n",
    "\n",
    "x = [ (tool, factor) for tool in tools for factor in factors]\n",
    "counts = sum(zip(data['stars'], data['commits'], data['contributors']),())\n",
    "source = ColumnDataSource(data=dict(\n",
    "    x = x,\n",
    "    counts = counts,\n",
    "))\n",
    "\n",
    "p = figure(\n",
    "    x_range = FactorRange(*x), \n",
    "    plot_height = 400,\n",
    "    plot_width = 800\n",
    ")\n",
    "\n",
    "p.vbar(\n",
    "    x = 'x',\n",
    "    top = 'counts',\n",
    "    width = 0.9,\n",
    "    source = source,\n",
    ")\n",
    "\n",
    "p.y_range.start = 0\n",
    "p.x_range.range_padding = 0.1\n",
    "p.xaxis.major_label_orientation = 1\n",
    "p.xgrid.grid_line_color = None\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "e1f9c715",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     9678\n",
       "1    11034\n",
       "2     5387\n",
       "3     6038\n",
       "4     4928\n",
       "5     3783\n",
       "Name: Star, dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "0dc899f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Visualization_tools</th>\n",
       "      <th>Watch</th>\n",
       "      <th>Star</th>\n",
       "      <th>Fork</th>\n",
       "      <th>Commits</th>\n",
       "      <th>Contributors</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>matplotlib</td>\n",
       "      <td>533</td>\n",
       "      <td>9678</td>\n",
       "      <td>4143</td>\n",
       "      <td>29503</td>\n",
       "      <td>808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bokeh</td>\n",
       "      <td>396</td>\n",
       "      <td>11034</td>\n",
       "      <td>2526</td>\n",
       "      <td>17673</td>\n",
       "      <td>357</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>pyecharts</td>\n",
       "      <td>263</td>\n",
       "      <td>5387</td>\n",
       "      <td>1148</td>\n",
       "      <td>1321</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>seaborn</td>\n",
       "      <td>234</td>\n",
       "      <td>6038</td>\n",
       "      <td>970</td>\n",
       "      <td>2316</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>plotly</td>\n",
       "      <td>234</td>\n",
       "      <td>4928</td>\n",
       "      <td>1114</td>\n",
       "      <td>3370</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ggplot2</td>\n",
       "      <td>329</td>\n",
       "      <td>3783</td>\n",
       "      <td>1427</td>\n",
       "      <td>4286</td>\n",
       "      <td>184</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Visualization_tools  Watch   Star  Fork  Commits  Contributors\n",
       "0          matplotlib    533   9678  4143    29503           808\n",
       "1               bokeh    396  11034  2526    17673           357\n",
       "2           pyecharts    263   5387  1148     1321            18\n",
       "3             seaborn    234   6038   970     2316            98\n",
       "4              plotly    234   4928  1114     3370            76\n",
       "5             ggplot2    329   3783  1427     4286           184"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "530eee1f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
